package test.rmi.zookeeper;

import java.io.IOException;
import java.util.Random;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooDefs.Ids;
import org.apache.zookeeper.ZooKeeper;

public class Server {
	
	static String url = "localhost:2181";
	static String path = "/test";
	
	public static void main(String[] args) throws IOException {
		ZooKeeper zk = new ZooKeeper(url, 5000, new Watcher() {
			@Override
			public void process(WatchedEvent event) {
				
			}
		});
		try {
			zk.create(path+"/haha", (new Random().nextInt(9)+"").getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
			Thread.sleep(10000);
		} catch (KeeperException | InterruptedException e) {
			e.printStackTrace();
		}
	}

}
